package com.lzy.cloud.mq.service;

import com.lzy.cloud.mq.config.ConfigMq;
import com.lzy.cloud.mq.remote.OrderApi;
import com.lzy.cloud.mq.remote.dtos.OrderInfoDto;
import lombok.extern.java.Log;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;




/**
 * Created with IntelliJ IDEA.
 * Description: lzy-cloud-service
 *
 * @author: ellengou
 * @date: 2018-07-18 星期三
 * @time: 11:50
 */
@Component
@Log
public class OrderReceiver {
    @Autowired
    OrderApi orderApi;
    //监听队列消息-订单过期
    @RabbitListener(queues = ConfigMq.REGISTER_QUEUE_NAME)
    @RabbitHandler
    public void receive(String orderId) {
        log.info("order.cancel receive message: "+orderId);
        OrderInfoDto orderInfoDto = new OrderInfoDto();
        orderInfoDto.setOrderId(orderId);
        orderApi.cancel(orderId);
    }

}
